<#if invalid?? && invalid>
<div class="alert alert-danger" role="alert">
	<strong>警告！</strong>
	无效的招标信息或文件类型！
</div>
<#else>
<form class="bid-file-upload-form" action="${request.contextPath}/bid/common-file-upload" method="post" enctype="multipart/form-data">
	<input type="hidden" name="bidId" value="${bidId}">
	<input type="hidden" name="fileType" value="${fileType}">
	<div class="row">
		<div class="col-md-12">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div class="form-item-title">
							<span class="not-null-star">*</span>
							${fileType.value}
						</div>
					</div>
					<input type="file" name="file" class="hidden" ${((suffix??)?string('data-suffix="' + suffix + '"',''))!''}>
					<input type="text" class="form-control not-empty file-show" placeholder="请选择相关文件。${((suffix??)?string('格式只能是[' + suffix + ']中的一个！',''))!''}" readonly="readonly">
				</div>
			</div>
		</div>
	</div>
	<hr>
	<div class="row">
		<div class="col-md-12 text-right">
			<div class="btn btn-primary btn-sm btn-submit">确定</div>
			&nbsp;
			<div class="btn btn-default btn-sm" onclick="$.suredy.closeModal();">关闭</div>
		</div>
	</div>
</form>
<script type="text/javascript">
	$(function() {
		// 提交表单
		$('.btn.btn-submit').on('click', function() {
			var form = $('form.bid-file-upload-form');

			// 校验表单
			if (!$.suredy.formChecker(form)) {
				return false;
			}

			var $this = $(this);

			if ($this.hasClass('disabled'))
				return false;

			$this.addClass('disabled');

			form.ajaxSubmit({
				dataType : "json",
				success : function(data, textStatus, jqXHR) {
					if (!data || !data.success) {
						alert(data.msg || '上传文件失败！');
						$this.removeClass('disabled');
						return false;
					}

					$.suredy.refreshContent('${bidId}', [ 'div.bid-files' ]);

					$.suredy.closeModal();
				},
				error : function(jqXHR, textStatus, errorThrown) {
					alert('上传文件失败！\n' + errorThrown);
					$this.removeClass('disabled');
					return false;
				}
			});
		});

	});
</script>
</#if>
